/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Riset1;
import java.rmi.*;
import java.rmi.server.UnicastRemoteObject;
import java.util.ArrayList;
import amd.database.ConnectDB;
import amd.database.DbDocument;
import amd.database.DbDocumentSimilarity;

/**
 *
 * @author Presario
 */

public class QProcImpl extends UnicastRemoteObject implements QProcessor {
     public QProcImpl() throws RemoteException {
	}
	public ArrayList<ArrayList<String>> SearchDokRelevan(String s[]) throws RemoteException {
		ArrayList<ArrayList<String>> hasilQterm =
			new ArrayList<ArrayList<String>>();
       try {
            ConnectDB conn=null;
            conn = new ConnectDB("jdbc:mysql://localhost:3306/db_amd_lsa", "root", "");
            hasilQterm = SearchTerm.Search(s,conn);

//           hasilQterm = JDialogSearch.queryRelevan(s);
         }
         catch(Exception Ex){
            System.out.println(Ex.toString());
         }
         return hasilQterm;
	}

	public ArrayList<String> getIsiDoc(String s) throws RemoteException {
        ArrayList<String> isiDocs= new ArrayList<String>();
        DbDocument dbDoc=new DbDocument();
        try{
            ConnectDB conn=null;
            conn = new ConnectDB("jdbc:mysql://localhost:3306/db_amd_lsa", "root", "");
            isiDocs= dbDoc.getDataDocument(conn, s);
        }catch(Exception ex){
            System.out.println(ex.toString());
        }
		 return isiDocs;
    }

    public ArrayList<ArrayList<String>> getDokumenMirip (String s) throws RemoteException {
        ArrayList<ArrayList<String>> similarDocs = new ArrayList<ArrayList<String>>();
        DbDocumentSimilarity dbDocSimilar=new DbDocumentSimilarity();
        try{
            ConnectDB conn=null;
            conn = new ConnectDB("jdbc:mysql://localhost:3306/db_amd_lsa", "root", "");
			similarDocs = dbDocSimilar.getDocumentSimilar(conn, s);
		} catch(Exception ex){
			System.out.println(ex.toString());
        }
        return similarDocs;
    }

}